package converter.util

class MultiProjectChecker {
	
	private File pom
	private def project
	
	MultiProjectChecker(File pom) {
		this.pom = pom
		project = new XmlSlurper().parse(pom)
	}
	
	boolean isMultiProject() {
		boolean check = false
		if( project.packaging == "pom") {
				check = !(getModuleList().empty)
		}
		return check
	}
	

	List getModuleList() {
		List modules = []
		project.modules.module.each {
			modules << it
		}
		return modules
	}
	
	Map getModulesFileMap() {
		Map map = [:]
		getModuleList().each{
			String module = it.text()
			map[module] = new File(pom.parent + "/$module/pom.xml")
		}
		return map
	} 	
}
